/**
 * Package:com.goldcitynet.util;
 * $Id: Util.java,v 1.1.1.1 2009/03/23 09:21:18 zhangpei Exp $
 * Copyright(c) 2001-2005 www.afteryuan.com
 */
package com.afteryuan.util;

import com.afteryuan.jtc.Digest;

import org.apache.xpath.XPathAPI;

/**
 * Util
 * <p/>
 * <p><a href="Util.java.html"><i>View Source</i></a></p>
 *
 * @author <a href="mailto:afteryuan@afteryuan.com">$Author: zhangpei $</a>
 * @version $Revision: 1.1.1.1 $
 */
public class Util {
    public static Integer convertRank(Integer experience){
        return experience/1000+1;    
    }

    public static void main(String[] args) {

        System.out.println(Digest.digestMD5HexString("111111"));
    }

    /**
     * 判断是否是32位ID值
     * @param unique
     * @return
     */
    public static boolean isEntityId(String unique) {
        return unique.length() == 32;
    }

    /**
     * 判断是否是金城号
     * @param unique
     * @return
     */
    public static boolean isGoldCode(String unique) {
        if(unique.length()>=32)return false;
        try {
            Integer code = Integer.parseInt(unique);
            if(code>10000) return true;
        } catch (NumberFormatException e) {
//            e.printStackTrace();
            return false;
        }
        return false;
    }
    /**
     * 判断是否是用户名
     * @param unique
     * @return
     */
    public static boolean isLoginName(String unique) {
        //todo 用户名和昵称暂时无法区分
        if(!isGoldCode(unique) && unique.length()<32)return true;
        return false;
    }

//    public static boolean isLogined(HttpServletRequest request, PublicUser publicUser) {
//        return false;
//    }

}
